package com.itheima.service.impl;

import com.itheima.dao.Repository.BusGoodsResponsitory;
import com.itheima.model.domain.BusGoodsInfo;
import com.itheima.model.domain.BusUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusGoodsSevice {
    @Autowired
    private BusGoodsResponsitory busComRepository;

    public List<BusGoodsInfo> findGoodsByName(String bus_user_name){

        return busComRepository.findGoodsByName(bus_user_name);
    };


    public List<BusGoodsInfo> AllGoodsById(int bus_user_id){
        return busComRepository.AllGoodsById(bus_user_id);
    }

    public List<BusGoodsInfo> findAll(){return busComRepository.findAll();}

    public void deleteBusGoodsInfoById(int id){busComRepository.deleteBusGoodsInfoById(id);}

    public List<BusGoodsInfo> searchByGoodsname(String keyword) {
        return busComRepository.findByGoodsnameContaining(keyword);
    }
    public BusGoodsInfo findBusGoodsById(int id){
        BusGoodsInfo  busGoodsInfo=busComRepository.findBusGoodsById(id);
        return busGoodsInfo;
    }

    public void updateBusGoodsInfo(BusGoodsInfo busGoodsInfo){
        busComRepository.updateBusUserInfo(busGoodsInfo);
    }



}
